home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / Include / netTypes.h < prev    next >
C/C++ Source or Header  |  1991-03-30  |  7KB  |  204 lines

  1. /*
  2.  * netTypes.h --
  3.  *
  4.  *    This defines the types and contants for the networking software.
  5.  *
  6.  * Copyright 1985, 1988 Regents of the University of California
  7.  * Permission to use, copy, modify, and distribute this
  8.  * software and its documentation for any purpose and without
  9.  * fee is hereby granted, provided that the above copyright
  10.  * notice appear in all copies.  The University of California
  11.  * makes no representations about the suitability of this
  12.  * software for any purpose.  It is provided "as is" without
  13.  * express or implied warranty.
  14.  *
  15.  *
  16.  * $Header: /sprite/src/kernel/net/RCS/netTypes.h,v 1.6 91/03/30 17:19:02 mgbaker Exp $ SPRITE (Berkeley)
  17.  */
  18.  
  19. #ifndef _NETTYPES
  20. #define _NETTYPES
  21.  
  22. #ifdef KERNEL
  23. #include <netEther.h>
  24. #include <user/net.h>
  25. #include <syncTypes.h>
  26. #include <fs.h>
  27. #else
  28. #include <netEther.h>
  29. #include <net.h>
  30. #include <kernel/syncTypes.h>
  31. #include <kernel/fs.h>
  32. #endif
  33.  
  34. /*
  35.  * This define is used by the net module in maintaining routing
  36.  * information.  It is needed by other modules that maintain state
  37.  * about the various Sprite hosts.
  38.  */
  39.  
  40. #define NET_NUM_SPRITE_HOSTS    200
  41.  
  42. /*
  43.  * Maximum number of network interfaces a host may have.
  44.  */
  45.  
  46. #define NET_MAX_INTERFACES    2
  47.  
  48. /*
  49.  * Constants defining the different types of packets.
  50.  */
  51.  
  52. #define NET_PACKET_UNKNOWN    0x0
  53. #define NET_PACKET_SPRITE    0x1
  54. #define NET_PACKET_ARP        0x2
  55. #define NET_PACKET_RARP        0x3
  56. #define NET_PACKET_DEBUG    0x4
  57. #define NET_PACKET_IP        0x5
  58.  
  59. /*
  60.  * Scatter/gather vector element.  The network output routines take
  61.  * an array of these elements as a specifier for the packet.  This
  62.  * format lets clients of the network module save extra copies because
  63.  * they can leave data objects where they lie.  The done and mutexPtr
  64.  * parts are used to wait for the packet to be truely output.  The
  65.  * mutex is released while the packet is output.
  66.  */
  67.  
  68. typedef struct {
  69.     Address        bufAddr;    /* In - Buffer address */
  70.     int            length;        /* In - Size of the buffer */
  71.     Sync_Semaphore    *mutexPtr;    /* Private to net module.
  72.                      * Used to wait for output. */
  73.     Boolean        done;        /* Out - set when I/O completes */
  74.     void        ((*callBackFunc)());    /* Call-back to say when
  75.                          * we're done sending packet. */
  76.     ClientData        clientData;    /* Client data to pass to call-back. */
  77. } Net_ScatterGather;
  78.  
  79. /*
  80.  * Statistics - the ethernet drivers record the number of occurences
  81.  *    of various events.
  82.  */
  83. typedef struct {
  84.     int    packetsRecvd;        /* # packets received of any type */
  85.     int    packetsSent;        /* # packets sent of any type */
  86.     int    packetsOutput;        /* # packets output of any type */
  87.     int broadRecvd;        /* # broadcast packets received */
  88.     int broadSent;        /* # broadcast packets sent */
  89.     int others;            /* # packets between two other machines */
  90.     int overrunErrors;        /* # packets received with overrun errors. */
  91.     int crcErrors;        /* # packets received with CRC errors. */
  92.     int fcsErrors;        /* # packets received with FCS errors */
  93.     int frameErrors;        /* # packets received with framing errors */
  94.     int rangeErrors;        /* # packets received with range errors */
  95.     int collisions;        /* # of collisions on transmissions */
  96.     int xmitCollisionDrop;    /* # of packets dropped because of too many
  97.                    collisions. */
  98.     int    xmitPacketsDropped;    /* # transmitted packets that are dropped */
  99.     int    recvPacketsDropped;    /* # transmitted packets that are dropped */
  100.     int matches;        /* # of address match packets */
  101.     int recvAvgPacketSize;    /* average size of packets received */
  102.     int recvAvgLargeSize;    /*  ...  of more than 100 bytes */
  103.     int recvAvgSmallSize;    /*  ...  of less than 100 bytes */
  104.     int sentAvgPacketSize;    /* average size of packets sent */
  105.     int sentAvgLargeSize;    /*  ...  of more than 100 bytes */
  106.     int sentAvgSmallSize;    /*  ...  of less than 100 bytes */
  107.     int    bytesSent;        /* Total number of bytes transmitted. */
  108.     int    bytesReceived;        /* Total number of bytes received. */
  109. } Net_EtherStats;
  110.  
  111. /*
  112.  * Statistics for the UltraNet interface. 
  113.  */
  114. typedef struct Net_UltraStats {
  115.     int        packetsSent;        /* Number of packets sent. */
  116.     int        bytesSent;        /* Number of bytes sent. */
  117.     int        sentHistogram[33];    /* Histogram of bytes sent 
  118.                      * (1K buckets). */
  119.     int        packetsReceived;    /* Number of packets received. */
  120.     int        bytesReceived;        /* Number of bytes received. */
  121.     int        receivedHistogram[33];    /* Histogram of bytes received
  122.                      * (1K buckets). */
  123. } Net_UltraStats;
  124.  
  125. /*
  126.  * Statistics in general.
  127.  */
  128.  
  129. typedef struct Net_Stats {
  130.     Net_EtherStats    ether;
  131.     Net_UltraStats    ultra;
  132. } Net_Stats;
  133.  
  134. /*
  135.  * Structure that defines a network interface.
  136.  */
  137.  
  138. typedef struct Net_Interface {
  139.     char        *name;        /* Name of the interface. */
  140.     int             unit;        /* Unit number of device. */
  141.     Address        ctrlAddr;    /* Address of control register. */
  142.     Boolean        virtual;    /* Is ctrlAddr in kernel VM? */
  143.     int            vector;        /* Interrupt vector generated by 
  144.                      * device. */
  145.  
  146.             /* Initialization routine. */
  147.     ReturnStatus    (*init) _ARGS_((struct Net_Interface *interPtr));
  148.  
  149.             /* Output a packet. */
  150.     ReturnStatus    (*output) _ARGS_((struct Net_Interface *interPtr,
  151.                 Address packetHeader, 
  152.                 Net_ScatterGather *scatterGatherPtr,
  153.                 int scatterGatherLength, Boolean rpc,
  154.                 ReturnStatus *statusPtr));
  155.  
  156.             /* Handle an interrupt. */
  157.     void         (*intr) _ARGS_((struct Net_Interface *interPtr, 
  158.                 Boolean polling));    
  159.  
  160.             /* Reset the interface */
  161.     void         (*reset) _ARGS_ ((struct Net_Interface *interPtr));    
  162.  
  163.             /* Perform ioctls on interface. */
  164.     ReturnStatus    (*ioctl) _ARGS_((struct Net_Interface *interPtr,
  165.                 Fs_IOCParam *ioctlPtr, Fs_IOReply *replyPtr));    
  166.  
  167.             /* Get performance statistics. */
  168.     ReturnStatus    (*getStats) _ARGS_((struct Net_Interface *interPtr,
  169.                 Net_Stats *statPtr));    
  170.  
  171.     int            number;        /* Interface number. */
  172.     Net_NetworkType    netType;    /* Type of interface. See below. */
  173.     int            flags;        /* Status flags. See below. */
  174.     Sync_Semaphore    syncOutputMutex;/* Used to wait for packets
  175.                      * to be output. */
  176.     Sync_Semaphore    mutex;        /* Protects network interface board
  177.                      * and related data structures. */
  178.     int            maxBytes;    /* Maximum transfer unit 
  179.                      * (packet size) */
  180.     int            minBytes;    /* Minimum transfer unit. */
  181.  
  182.             /* Packet handler for network device driver. */
  183.     void        (*packetProc) _ARGS_((struct Net_Interface *interPtr,
  184.                 int packetLength, Address packetPtr));
  185.  
  186.     ClientData        interfaceData;    /* Place for the interface routines
  187.                      * store store stuff. */
  188.     ClientData        devNetData;    /* Place for the network device
  189.                      * driver to store stuff. */
  190.     Net_Address        netAddress[NET_MAX_PROTOCOLS];
  191.     Net_Address        broadcastAddress; /* Broadcast address for this
  192.                        * interface. */
  193. } Net_Interface;
  194.  
  195. /*
  196.  * Flag values for Net_Interface.
  197.  */
  198.  
  199. #define NET_IFLAGS_RUNNING    0x1    /* The interface is active. */
  200. #define NET_IFLAGS_BROADCAST    0x2    /* Interface supports broadcast. */
  201.  
  202.  
  203. #endif /* _NETTYPES */
  204.